1
2
3
4
5
6
7
8
9
10
11 package org.votech.ds6.plastlets;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15
16 /*** Check that the JDIC system browser is available.
17 * @author Noel Winstanley nw@jb.man.ac.uk 21-Jun-2005
18 * @author canabalised by jdt@roe.ac.uk april 2006
19 *
20 */
21 public class CheckJDICPresent implements Check {
22 /***
23 * Commons Logger for this class
24 */
25 private static final Log logger = LogFactory.getLog(CheckJDICPresent.class);
26
27
28 public final static GeneralClassPresentCheck systemTray = new GeneralClassPresentCheck("org.jdesktop.jdic.tray.SystemTray");
29 public final static GeneralClassPresentCheck browser = new GeneralClassPresentCheck("org.jdesktop.jdic.browser.WebBrowser");
30 public final static GeneralClassPresentCheck desktop = new GeneralClassPresentCheck("org.jdesktop.jdic.desktop.Desktop");
31
32 /***
33 * Check them all
34 */
35 public boolean check() {
36 return systemTray.check() && browser.check() && desktop.check();
37 }
38
39 public static class GeneralClassPresentCheck implements Check {
40 private String clazz;
41 public GeneralClassPresentCheck(String className) {
42 this.clazz = className;
43 }
44 public boolean check() {
45 try {
46 logger.info("Checking for class "+clazz);
47 Class jdic = Class.forName(clazz);
48 if (jdic != null) {
49 return true;
50 }
51 } catch (NoClassDefFoundError e) {
52 logger.info("Class not present");
53 } catch (ClassNotFoundException e) {
54 logger.info("Class not present");
55 } catch (UnsatisfiedLinkError e) {
56
57 logger.info("Class present, but binary libraries are not.");
58 }
59 return false;
60 }
61 }
62
63
64
65
66
67 }
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93